<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :advOptions="[]"
      :dictMap="dictMap"
      :formOptions="formOptions"
      :outputQueryParams="queryParams"
      :queryParams="queryParams"
      :defaultEventKey="defaultEventKey"
      :labelWidth="75"
    ></Ht-search-form>

    <ht-table
      :defaultEventKey="defaultEventKey"
      ref="dataTable"
      :dictMap="dictMap"
      :multi-select="false"
      :opButtonList="opButtonList"
      :queryParams="queryParams"
      :reqConfig="regConfig"
      :showSerialNumber="false"
      :tableBindColumns="tableBindColumns"
      :randomRowKey="true"
    >
      <template v-slot:operate>
        <el-table-column align="left" fixed="right" label="操作" width="120">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
                 {
                  label: '应答明细',
                  visible: (scope.row.status === '06' || scope.row.status === '05'),
                  doFunc: () => {
                    resDetail(scope.row);
                  },
                },

              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      :close-on-click-modal="false"
      :title="title"
      center
      :visible.sync="open"
      v-if="open"
      append-to-body
      width="1024px"
    >
      <el-form ref="detailForm" :model="detailForm" label-width="140px">
        <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span></span>
        </div>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="detailForm.id" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报文标识号" prop="pkgId">
              <el-input v-model="detailForm.pkgId" :disabled="true"/>
            </el-form-item>
          </el-col>

        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="CPG日期" prop="vdate">
              <el-date-picker
                v-model="detailForm.vdate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工作日期" prop="workdate">
              <el-date-picker
                v-model="detailForm.workdate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="发起直接参与机构号" prop="directSender">
              <el-input v-model="detailForm.directSender" :disabled="true"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="发起直接参与机构名称" prop="directSenderName">
              <el-input v-model="detailForm.directSenderName" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="接收直接参与机构号" prop="directRecver">
              <el-input v-model="detailForm.directRecver" :disabled="true"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="接收直接参与机构名称" prop="directRecverName">
              <el-input v-model="detailForm.directRecverName" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="查询账户数目" prop="acctCnt">
              <el-input v-model="detailForm.acctCnt" :disabled="true"/>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="业务状态" prop="status">
              <el-select style="width: 100%;" v-model="detailForm.status" :disabled="true" placeholder="业务状态">
                <el-option
                  v-for="dict in dictMap.PKG_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

        </el-row>
        </el-card>

        <div class="discountReceipt-pick-operate-box">
          <div class="operate-box-bottom">
            <div class="bottom-content">
          <ht-table
            ref="dataTable"
            :multi-select="false"
            :showSerialNumber="false"
            :dictMap="dictMap"
            :queryParams="queryDetailParams"
            :tableBindColumns="tableBindDetailColumns"
            :opButtonList="opButtonList"
            :reqConfig="regConfigDetail"
            :showRightToolbar="false"
          >
          </ht-table>
            </div>
          </div>
        </div>
      </el-form>

      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :close-on-click-modal="false"
      :title="restitle"
      :visible.sync="resopen"
      v-if="resopen"
      center
      append-to-body
      width="1024px"
    >
      <el-form ref="resdetailForm" :model="resdetailForm" :disabled="true" label-width="140px">
        <div slot="header" class="label-header-msg">
          <span></span>
        </div>
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>应答交易明细</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="应答交易流水号" prop="btId">
                <el-input v-model="resdetailForm.btId" :disabled="true" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <ht-table
              ref="dataTable"
              :multi-select="false"
              :showSerialNumber="false"
              :dictMap="dictMap"
              :queryParams="resqueryDetailParams"
              :tableBindColumns="restableBindDetailColumns"
              :opButtonList="opButtonList"
              :reqConfig="resregConfigDetail"
              :showPagination="false"
            />
          </el-row>
        </el-card>
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>原交易信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="id">
                <el-input v-model="resdetailForm.id" :disabled="true" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgId">
                <el-input v-model="resdetailForm.pkgId" />
              </el-form-item>
            </el-col>

          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="vdate">
                <el-date-picker
                  v-model="resdetailForm.vdate"
                  style="width: 100%"
                  type="date"
                  value-format="yyyyMMdd"
                  :disabled="true"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工作日期" prop="workdate">
                <el-date-picker
                  v-model="resdetailForm.workdate"
                  style="width: 100%"
                  type="date"
                  value-format="yyyyMMdd"
                  :disabled="true"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="发起直接参与机构号" prop="directSender">
                <el-input v-model="resdetailForm.directSender" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="发起直接参与机构名称" prop="directSenderName">
                <el-input v-model="resdetailForm.directSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="接收直接参与机构号" prop="directRecver">
                <el-input v-model="resdetailForm.directRecver" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="接收直接参与机构名称" prop="directRecverName">
                <el-input v-model="resdetailForm.directRecverName" />
              </el-form-item>
            </el-col>
          </el-row>


          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="查询账户数目" prop="acctCnt">
                <el-input v-model="resdetailForm.acctCnt" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="业务状态" prop="status">
                <el-select style="width: 100%;" v-model="resdetailForm.status" placeholder="业务状态">
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

          </el-row>
        </el-card>



      </el-form>

      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" @click="rescancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  apiUrlConfigQuery,
  apiUrlConfigQuerySearchTable,
  apiUrlConfigQuerySearchTableResp,
} from "@/api/cnaps/beps/394";
import { listPageMixin } from "@/libs/listPageMixin";
import HtAmountInput from "@/views/components/HtAmountInput";
export default {
  name: "BatchCustomerAccountQuery",
  mixins: [listPageMixin],
  components: { HtAmountInput },
  data() {
    return {
      defaultEventKey: "defaultEventKey",
      // 查询参数
      queryParams: {
        idSeqno:'',
        pkgId:'',
        startcpgdate:'',
        endcpgdate:'',
        startworkdate:'',
        endworkdate:'',


      },
      queryDetailParams:{
        id: undefined,
      },
      resqueryDetailParams:{
        btId: undefined,
      },
      // 搜索
      formOptions: [],
      //
      searchFormDictList: [
        'PKG_STATUS','VERIFICATION_RTCODE','PROCESSSTATUS','ACCOUNTSTATUSCODE'
      ],
      // 列信息
      regConfig: apiUrlConfigQuery,
      //明细表信息
      regConfigDetail:apiUrlConfigQuerySearchTable,

      resregConfigDetail:apiUrlConfigQuerySearchTableResp,

      tableBindColumns: [
        { prop: 'id',   label: '交易流水号'},
        { prop: 'vdate',   label: 'CPG日期', type:'date'},
        { prop: 'workdate',   label: '工作日期', type:'date'},
        { prop: 'pkgId',   label: '报文标识号'},
        { prop: 'acctCnt',   label: '查询账户数目'},
        { prop: 'status',   label: '业务状态', dictCode : 'PKG_STATUS' },
      ],
      tableBindDetailColumns:[
        { prop: 'acctCardNo',  label: '账户账号(卡号)',width:240},
        { prop: 'acctnm',  label: '账户名称',width:120},
        { prop: 'acctBrno',  label: '开户银行行号',width:120},
        { prop: 'acctBrname',  label: '开户银行行名',width:300},
        { prop: 'ctznidnb',  label: '公民身份号码',width:120},
        { prop: 'telephone',  label: '电话/电挂',width:120},
      ],
      restableBindDetailColumns:[
        { prop: 'acctCardNo',  label: '账户账号(卡号)',width:240},
        { prop: 'acctnm',  label: '账户名称',width:120},
        { prop: 'acctBrno',  label: '开户银行行号',width:120},
        { prop: 'acctBrname',  label: '开户银行行名',width:300},
        { prop: 'ctznidvfyrslt',  label: '公民身份号码校验结果', dictCode:'VERIFICATION_RTCODE' ,width:180},
        { prop: 'telvfyrslt',  label: '电话/电挂校验结果', dictCode:'VERIFICATION_RTCODE' ,width:180},
        { prop: 'bizStatus',  label: '业务应答状态', dictCode:'PROCESSSTATUS' ,width:120},
        { prop: 'bizRejectCode',  label: '业务拒绝处理码', formatter(row, text, index) {
            return (row["bizRejectCode"] === null ||row["bizRejectCode"]===undefined? "" : row["bizRejectCode"]) + "-" + (row["bizRejectCodeDesc"] === null||row["bizRejectCodeDesc"]===undefined ? "" : row["bizRejectCodeDesc"]);
          } ,width:180},
        { prop: 'acctsts',  label: '账户状态', dictCode:'ACCOUNTSTATUSCODE' ,width:120},
      ],

      dictMapAsync: {},
      // 弹出层标题
      title: "",
      restitle: "",
      // 是否显示弹出层
      open: false,
      resopen: false,
      // 表单参数
      detailForm: {

      },
      resdetailForm: {

      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索
      {
        type: "input",
        prop: "idSeqno",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },

      {
        type: "input",
        prop: "pkgId",
        defaultAttr: {
          size: "small",
          label: "报文标识号",
          placeholder: "请输入报文标识号",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "startcpgdate",
          endTimeName: "endcpgdate",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG开始日期", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "startworkdate",
          endTimeName: "endworkdate",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */

    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },
    rescancel(){
      this.resopen = false;
    },
    /** 详情按钮操作 */
    handleDetail(row) {

        this.title = "批量客户账户信息查询明细";
        this.detailForm = row;
        this.queryDetailParams.id=row.id;
        this.open = true;

    },
    /** 应答详情按钮操作 */
    resDetail(row){
      this.restitle = "批量客户账户信息查询应答明细";
      this.resdetailForm = row;
      this.resqueryDetailParams.btId=row.btId
      this.resopen = true;
    }
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>

